<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>

<head>
<meta charset="utf-8">
	<title>恒铸智能柜管理平台</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/resources/layui/css/layui.css" media="all" />
	<script type="text/javascript" src="${pageContext.request.contextPath}/resources/layui/layui.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/resources/js/cacheUserInfo.js"></script>
	<script type="text/javascript">
		layui.use([ 'jquery', 'layer', 'form','table', 'element' ],
			function() {var form = layui.form, $ = layui.jquery;
			//监听select 内容变化
	        form.on("select(select)", function (f) {
           		payTypeSelect(f.value);
            })
 
            form.on("select(isMidwayFetch)", function (f) {
            	isMidwayFetchSelect(f.value);
            })

			form.on("submit(addFormAdd)",function(data) {
				var param = serializeNotNull($("#addTypeForm").serialize());
				/* console.log($("#addTypeForm").serialize())
				console.log(param) */
				$.post("/caseType/editCaseTyep",param,function(res) {
					if (res.success) {
						layer.msg("修改成功");
						setTimeout(function() {
							//parent.window.location.reload();
							var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
			                parent.layer.close(index);
			                parent.layui.table.reload('adminListTable') 
						},1000)
					} else {
						layer.msg(res.message);
					}
				})
			})
			$(function(){
				var payType = "${manageCaseType.payType}";
				payTypeSelect(payType);
				isMidwayFetchSelect("${manageCaseType.isMidwayFetch}");
				$("#demo").val(payType);
				layui.form.render('select');
	 		})
	 		
	 		function payTypeSelect(value){
	   			$(".13").attr("lay-verify", "required|units");
               	$(".12").attr("lay-verify", "required");
                if (value == 0) {
                   $(".1").hide();
                   $(".13").removeAttr("lay-verify");
                   $(".12").removeAttr("lay-verify");
               	} else if (value == 1) {
                   $(".1").show();
               	} else {
                   $(".1").hide();
                   $(".13").removeAttr("lay-verify");
                   $(".2").show();
               }			
	   		}
			function isMidwayFetchSelect(value){
				if(value == 1){
            		$(".isHalfwayRestart").show();
            	}else{
            		$(".isHalfwayRestart select").val("0");
            		layui.form.render("select")
            		$(".isHalfwayRestart").hide();
            	}
			}
			//重置表单
	        $(".resetFrom").on("click", function (f) {
           		$("#addTypeForm")[0].reset();  
           		var arr = $("#addTypeForm")[0].children;
           		for(var i =0 ;i<(arr.length-1);i++){
           			arr[i].children[1].children[0].value= "";
           		}
           		layui.form.render();
            })
		})
	
		function changeNumVal(parm,rplaceVal){
        	parseFloat(parm.value)>0?1+1:parm.value=rplaceVal;
        }
		function serializeNotNull(serStr){
		    return serStr.split("&").filter(str => !str.endsWith("=")).join("&");
		}
</script>
</head>

<style type="text/css">
.layui-form-item .layui-input-inline {
	width: 200px !important;
}

.layui-nav-child {
	border: 1px solid #e6e6e6 !important;
}

.layui-nav-child-child {
	border: 1px solid #e6e6e6 !important;
}

.sumbit {
	margin-left: 120px;
	position: absolute;
	z-index: -1;
}

a {
	color: #000000 !important;
}

ul li {
	background-color: white;
}

ul li a {
	padding: 0 !important;
}

span {
	color: #000000;
	line-height: 40px;
	text-align: center;
	display: block;
}

.layui-form-item .layui-input-inline {
	width: 200px !important;
}

.layui-nav-child {
	z-index: 999;
}

.layui-nav {
	background-color: #fff;
}

.layui-nav-child {
	display: none !important;
	position: relative;
}

.layui-nav-child-child {
	display: none;
	position: relative;
}

.layui-nav-tree {
	width: 100%;
}

.layui-nav-item:hover .layui-nav-child {
	display: block !important;
	text-align: center;
}

.layui-nav-item:hover {
	display: block;
	color: white;
}

.layui-nav-child-child {
	position: relative;
	left: 100%;
	top: -41px;
}

.li2 {
	height: 40px;
}

.li2:hover {
	background-color: #5FB878;
}

.li2:hover span {
	color: white !important;
}

.li2:hover .layui-nav-child-child {
	display: block;
}

.li3:hover {
	background-color: #5FB878;
}

.li3:hover a {
	color: white !important;
}

#addTypeForm {
	margin-top: 20px
}

.priceSize input {
	width: 66px;
	float: left;
}
</style>

<body class="childrenBody">
	<div class="layui-form-mid layui-word-aux" style="margin-left: 100px;">
		<g style="color: red!important;padding:5px;">*</g>
		为必填选项
	</div>
	<form class="layui-form" style="position: relative;" id="addTypeForm">
		<div class="layui-form-item">
			<label class="layui-form-label">名称</label>
			<div class="layui-input-inline">
				<input type="text" class="layui-input Name" id="name" name="name"
					value="${manageCaseType.name }" lay-verify="required"
					placeholder="名称"> <input type="hidden" name=typeId
					value="${manageCaseType.typeId }">
			</div>
			<div class="layui-form-mid layui-word-aux">*</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">计费方式</label>
			<div class="layui-input-inline">
				<select name="payType" lay-filter="select" id="demo">
					<option value="0">免费</option>
					<option value="1" selected="selected">计时</option>
					<option value="2">计次</option>
				</select>
				<!--  
				<select name="payType" lay-filter="select" id="demo1">
					<c:if test="${manageCaseType.payType == 0}">
						<option value="0" selected="selected">免费</option>
						<option value="1">计时</option>
						<option value="2">计次</option>
					</c:if>
					<c:if test="${manageCaseType.payType == 1}">
						<option value="0">免费</option>
						<option value="1" selected="selected">计时</option>
						<option value="2">计次</option>
					</c:if>
					<c:if test="${manageCaseType.payType == 2}">
						<option value="0">免费</option>
						<option value="1">计时</option>
						<option value="2" selected="selected">计次</option>
					</c:if>
				</select>
				-->
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">绑定手机</label>
			<div class="layui-input-inline">
				<select name="isBindMobile">
					<c:if test="${manageCaseType.isBindMobile == 0}">
						<option value="0" selected="selected">否</option>
						<option value="1">是</option>
					</c:if>
					<c:if test="${manageCaseType.isBindMobile == 1}">
						<option value="0">否</option>
						<option value="1" selected="selected">是</option>
					</c:if>
				</select>
			</div>
		</div>
		
		<div class="layui-form-item">
			<label class="layui-form-label">是否能中途取件</label>
			<div class="layui-input-inline">
				<select name="isMidwayFetch" lay-filter="isMidwayFetch">
					<c:if test="${manageCaseType.isMidwayFetch == 0}">
						<option value="0" selected="selected">否</option>
						<option value="1">是</option>
					</c:if>
					<c:if test="${manageCaseType.isMidwayFetch == 1}">
						<option value="0">否</option>
						<option value="1" selected="selected">是</option>
					</c:if>
				</select>
			</div>
		</div>

		<div class="layui-form-item isHalfwayRestart">
			<label class="layui-form-label">中途取件重新计费</label>
			<div class="layui-input-inline">
				<select name="isHalfwayRestart">
					<c:if test="${manageCaseType.isHalfwayRestart == 0}">
						<option value="0" selected="selected">否</option>
						<option value="1">是</option>
					</c:if>
					<c:if test="${manageCaseType.isHalfwayRestart == 1}">
						<option value="0">否</option>
						<option value="1" selected="selected">是</option>
					</c:if>
				</select>
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">收费时间</label>
			<div class="layui-input-inline">
				<select name="payTime">
					<c:if test="${manageCaseType.payTime == 1}">
						<option value="1" selected="selected">使用后</option>
						<option value="2">使用前</option>
					</c:if>
					<c:if test="${manageCaseType.payTime == 2}">
						<option value="1">使用后</option>
						<option value="2" selected="selected">使用前</option>
					</c:if>
				</select>
			</div>
		</div>

		<div class="layui-form-item 1 2">
			<label class="layui-form-label">价格</label>
			<div class="layui-input-inline">
				<input type="number" min="0.0" step="0.1"
					class="layui-input 12 price" value="${manageCaseType.price}"
					name="price" lay-verify="required" placeholder="请输入价格" onchange="changeNumVal(this,0)">
			</div>
			<div class="layui-form-mid layui-word-aux">*元</div>
		</div>

		<div class="layui-form-item 1 2">
			<label class="layui-form-label">押金</label>
			<div class="layui-input-inline">
				<input type="number" min="0.0" step="0.1"
					class="layui-input 12 price" value="${manageCaseType.cashPledge}"
					name="cashPledge" lay-verify="required" placeholder="请输入价格" onchange="changeNumVal(this,0)">
			</div>
			<div class="layui-form-mid layui-word-aux">*元</div>
		</div>

		<div class="layui-form-item 1 2">
			<label class="layui-form-label">价格(大中小)</label>
			<div class="layui-input-inline priceSize">
				<input type="number" min="0.0" step="0.1" class="layui-input price-1" value="${priceSize[0]}" name="priceSize" placeholder="大"> 
				<input type="number" min="0.0" step="0.1" class="layui-input price-2" value="${priceSize[1]}" name="priceSize" placeholder="中"> 
				<input type="number" min="0.0" step="0.1" class="layui-input price-3" value="${priceSize[2]}" name="priceSize" placeholder="小">
			</div>
		</div>

		<div class="layui-form-item 1">
			<label class="layui-form-label">计时单位</label>
			<div class="layui-input-inline">
				<input type="number" min="0.0" step="0.1"
					class="layui-input userTime 13" value="${manageCaseType.userTime}"
					lay-verify="required" name="userTime" placeholder="此价格使用的时间（计时）" onchange="changeNumVal(this,0)">
			</div>
			<div class="layui-form-mid layui-word-aux">*小时</div>
		</div>
		
		<div class="layui-form-item 1">
			<label class="layui-form-label">费用上限</label>
			<div class="layui-input-inline">
				<input type="number" min="0.0" step="0.1" class="layui-input" value="${manageCaseType.feeCap}"
					name="feeCap" placeholder="请输入金额"
					onchange="changeNumVal(this,null)">
			</div>
			<div class="layui-form-mid layui-word-aux">元</div>
		</div>
		
		<div class="layui-form-item">
			<label class="layui-form-label">公司</label>
			<div class="layui-input-inline">
				<select class="comp" name="compId" lay-verify="required">
					<option value="${manageCaseType.compId}">${list.compName}</option>
					<c:forEach items="${compList}" var="list">
						<c:if test="${list.compId == manageCaseType.compId}">
							<option value="${list.compId }" selected="selected">${list.compName}</option>
						</c:if>
						<c:if test="${list.compId != manageCaseType.compId}">
							<option value="${list.compId }">${list.compName}</option>
						</c:if>
					</c:forEach>
				</select>
			</div>
		</div>

		<div class="layui-form-item sumbit">
			<a class="layui-btn" lay-submit lay-filter="addFormAdd" type="sumbit">立即提交</a>
			<a class="layui-btn layui-btn-primary resetFrom" >重置</a>
		</div>
	</form>
</body>

</html>